package com.imooc.springboot.dubbo.nilinili.consumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.imooc.springboot.dubbo.nilinili.service.FanService;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/fan")
public class FanController {
    @Reference
    private FanService fanService;

    /**
     * 获取粉丝列表
     * @param token
     * @return
     */
    @GetMapping("/getFanList")
    public String getFanList(@RequestHeader("token") String token) {
        return fanService.getFanList(token);
    }

    /**
     * 获取关注列表
     * @param token
     * @return
     */
    @GetMapping("/getFollowedList")
    public String getFollowedList(@RequestHeader("token") String token) {
        return fanService.getFollowedList(token);
    }

    /**
     * 判断是否关注了当前用户
     * @param token
     * @param followedId
     * @return
     */

    @GetMapping("/getIsFollowed")
    public String getIsFollowed(@RequestHeader("token") String token, @RequestParam("followedId") String followedId) {
        return fanService.getIsFollowed(token, followedId);
    }

    /**
     * 关注
     * @param token
     * @param followedId
     * @return
     */
    @PostMapping("/followAction")
    public String followAction(@RequestHeader("token") String token, @RequestParam("followedId") String followedId) {
        return fanService.followAction(token, followedId);
    }

    /**
     * 取消关注
     * @param token
     * @param followedId
     * @return
     */
    @PostMapping ("/cancleFollowAction")
    public String unFollowAction(@RequestHeader("token") String token, @RequestParam("followedId") String followedId) {
        return fanService.cancleFollowAction(token, followedId);
    }
}
